package com.czy.seed.mvc.home.mapper;

import com.czy.seed.mvc.home.entity.OrderDetailVo;
import com.czy.seed.mvc.home.entity.QuoteOrCompare;
import com.czy.seed.mybatis.base.mapper.BaseMapper;
import com.czy.seed.mybatis.config.mybatis.annotations.AutoMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


@AutoMapper
public interface QuoteOrCompareMapper extends BaseMapper<QuoteOrCompare>{

    @Select("UPDATE quote_or_compare set QUOTATION_NUMBER = QUOTATION_NUMBER+1,updatetime=sysdate(),updateuserid=#{c_userid} WHERE ID = #{id}")

    void updateQuotationNumber(@Param("id") Long id,@Param("c_userid") Long c_userid);

    @Select("UPDATE quote_or_compare set type = #{type},updatetime=sysdate(),updateuserid=#{c_userid} WHERE ID = #{id}")

    void updateQuotationOrCompaer(@Param("id") Long id,@Param("type") Long type,@Param("c_userid") Long c_userid);
    @Select("SELECT\n" +
            "quote_or_compare.ID,\n" +
            "quote_or_compare.COMMODITY_NAME as commodityName,\n" +
            "quote_or_compare.COMMODITY_NUM as commodityNum,\n" +
            "quote_or_compare.PURCHASE_UNIT as purchaseUnit,\n" +
            "quote_or_compare.SHIPPING_ADDRESS as shippingAddress,\n" +
            "quote_or_compare.DEADLINE as deadline,\n" +
            "quote_or_compare.QUOTATION_NUMBER as quotationNumber,\n" +
            "quote_or_compare.TYPE,\n" +
            "quote_or_compare.NUMBER,\n" +
            "quote_or_compare.DELIVERY_DEADLINE as deliveryDeadline,\n" +
            "quote_or_compare.INITIATOR_ID as initiatorId,\n" +
            "quote_or_compare.CONTRAST_TYPE as contrastType,\n" +
            "quote_or_compare.CREATION_TIME as creationTime,\n" +
            "quote_or_compare.UPDATETIME,\n" +
            "quote_or_compare.VERSION,\n" +
            "quote_or_compare.PRICE_CAP as priceCap,\n" +
            "quote_or_compare.START_TIME  as startTime ,\n" +
            "quote_or_compare.POSTSCRIPT,\n" +
            "quote_or_compare.PURCHASE_ID as purchaseId,\n" +
            "quote_or_compare.UPDATEUSERID\n" +
            "FROM\n" +
            "quote_or_compare\n" +
            "INNER JOIN quotation ON quotation.QUOTE_OR_COMPARE_ID = quote_or_compare.ID\n" +
            "WHERE\n" +
            "quotation.IFSHOW =#{type}  order by quote_or_compare.ID desc")
    List<QuoteOrCompare>  selectAll(@Param("type") Long type);
}
